home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Actual 85 Febrero 2004.iso / Experto / Apache / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F251745_apr_general.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-03-05  |  9.2 KB  |  288 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_GENERAL_H
  56. #define APR_GENERAL_H
  57.  
  58. /**
  59.  * @file apr_general.h
  60.  * This is collection of oddballs that didn't fit anywhere else,
  61.  * and might move to more appropriate headers with the release
  62.  * of APR 1.0.
  63.  * @brief APR Miscellaneous library routines
  64.  */
  65.  
  66. #include "apr.h"
  67. #include "apr_pools.h"
  68. #include "apr_errno.h"
  69.  
  70. #if APR_HAVE_SIGNAL_H
  71. #include <signal.h>
  72. #endif
  73.  
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif /* __cplusplus */
  77.  
  78. /**
  79.  * @defgroup apr_general Miscellaneous library routines
  80.  * @ingroup APR 
  81.  * This is collection of oddballs that didn't fit anywhere else,
  82.  * and might move to more appropriate headers with the release
  83.  * of APR 1.0.
  84.  * @{
  85.  */
  86.  
  87. /** FALSE */
  88. #ifndef FALSE
  89. #define FALSE 0
  90. #endif
  91. /** TRUE */
  92. #ifndef TRUE
  93. #define TRUE (!FALSE)
  94. #endif
  95.  
  96. /** a space */
  97. #define APR_ASCII_BLANK  '\040'
  98. /** a carrige return */
  99. #define APR_ASCII_CR     '\015'
  100. /** a line feed */
  101. #define APR_ASCII_LF     '\012'
  102. /** a tab */
  103. #define APR_ASCII_TAB    '\011'
  104.  
  105. /** signal numbers typedef */
  106. typedef int               apr_signum_t;
  107.  
  108. /**
  109.  * Finding offsets of elements within structures.
  110.  * Taken from the X code... they've sweated portability of this stuff
  111.  * so we don't have to.  Sigh...
  112.  * @param p_type pointer type name
  113.  * @param field  data field within the structure pointed to
  114.  * @return offset
  115.  */
  116.  
  117. #if defined(CRAY) || (defined(__arm) && !defined(LINUX))
  118. #ifdef __STDC__
  119. #define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
  120. #else
  121. #ifdef CRAY2
  122. #define APR_OFFSET(p_type,field) \
  123.         (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
  124.  
  125. #else /* !CRAY2 */
  126.  
  127. #define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
  128.  
  129. #endif /* !CRAY2 */
  130. #endif /* __STDC__ */
  131. #else /* ! (CRAY || __arm) */
  132.  
  133. #define APR_OFFSET(p_type,field) \
  134.         ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
  135.  
  136. #endif /* !CRAY */
  137.  
  138. /**
  139.  * Finding offsets of elements within structures.
  140.  * @param s_type structure type name
  141.  * @param field  data field within the structure
  142.  * @return offset
  143.  */
  144. #if defined(offsetof) && !defined(__cplusplus)
  145. #define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
  146. #else
  147. #define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
  148. #endif
  149.  
  150. /** @deprecated @see APR_OFFSET */
  151. #define APR_XtOffset APR_OFFSET
  152.  
  153. /** @deprecated @see APR_OFFSETOF */
  154. #define APR_XtOffsetOf APR_OFFSETOF
  155.  
  156. #ifndef DOXYGEN
  157.  
  158. /* A couple of prototypes for functions in case some platform doesn't 
  159.  * have it
  160.  */
  161. #if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP) 
  162. #define strcasecmp(s1, s2) stricmp(s1, s2)
  163. #elif (!APR_HAVE_STRCASECMP)
  164. int strcasecmp(const char *a, const char *b);
  165. #endif
  166.  
  167. #if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
  168. #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
  169. #elif (!APR_HAVE_STRNCASECMP)
  170. int strncasecmp(const char *a, const char *b, size_t n);
  171. #endif
  172.  
  173. #endif
  174.  
  175. /**
  176.  * Alignment macros
  177.  */
  178.  
  179. /* APR_ALIGN() is only to be used to align on a power of 2 boundary */
  180. #define APR_ALIGN(size, boundary) \
  181.     (((size) + ((boundary) - 1)) & ~((boundary) - 1))
  182.  
  183. /** Default alignment */
  184. #define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
  185.  
  186.  
  187. /**
  188.  * String and memory functions
  189.  */
  190.  
  191. /** Properly quote a value as a string in the C preprocessor */
  192. #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
  193. /** Helper macro for APR_STRINGIFY */
  194. #define APR_STRINGIFY_HELPER(n) #n
  195.  
  196. #if (!APR_HAVE_MEMMOVE)
  197. #define memmove(a,b,c) bcopy(b,a,c)
  198. #endif
  199.  
  200. #if (!APR_HAVE_MEMCHR)
  201. void *memchr(const void *s, int c, size_t n);
  202. #endif
  203.  
  204. /** @} */
  205.  
  206. /**
  207.  * @defgroup apr_library Library initialization and termination
  208.  * @{
  209.  */
  210.  
  211. /**
  212.  * Setup any APR internal data structures.  This MUST be the first function 
  213.  * called for any APR library.
  214.  * @remark See apr_app_initialize if this is an application, rather than
  215.  * a library consumer of apr.
  216.  */
  217. APR_DECLARE(apr_status_t) apr_initialize(void);
  218.  
  219. /**
  220.  * Set up an application with normalized argc, argv (and optionally env) in
  221.  * order to deal with platform-specific oddities, such as Win32 services,
  222.  * code pages and signals.  This must be the first function called for any
  223.  * APR program.
  224.  * @param argc Pointer to the argc that may be corrected
  225.  * @param argv Pointer to the argv that may be corrected
  226.  * @param env Pointer to the env that may be corrected, may be NULL
  227.  * @remark See apr_initialize if this is a library consumer of apr.
  228.  * Otherwise, this call is identical to apr_initialize, and must be closed
  229.  * with a call to apr_terminate at the end of program execution.
  230.  */
  231. APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, 
  232.                                              char const * const * *argv, 
  233.                                              char const * const * *env);
  234.  
  235. /**
  236.  * Tear down any APR internal data structures which aren't torn down 
  237.  * automatically.
  238.  * @remark An APR program must call this function at termination once it 
  239.  *         has stopped using APR services.  The APR developers suggest using
  240.  *         atexit to ensure this is called.  When using APR from a language
  241.  *         other than C that has problems with the calling convention, use
  242.  *         apr_terminate2() instead.
  243.  */
  244. APR_DECLARE_NONSTD(void) apr_terminate(void);
  245.  
  246. /**
  247.  * Tear down any APR internal data structures which aren't torn down 
  248.  * automatically, same as apr_terminate
  249.  * @remark An APR program must call either the apr_terminate or apr_terminate2 
  250.  *         function once it it has finished using APR services.  The APR 
  251.  *         developers suggest using atexit(apr_terminate) to ensure this is done.
  252.  *         apr_terminate2 exists to allow non-c language apps to tear down apr, 
  253.  *         while apr_terminate is recommended from c language applications.
  254.  */
  255. APR_DECLARE(void) apr_terminate2(void);
  256.  
  257. /** @} */
  258.  
  259. /**
  260.  * @defgroup apr_random Random Functions
  261.  * @{
  262.  */
  263.  
  264. #if APR_HAS_RANDOM || defined(DOXYGEN)
  265.  
  266. /* TODO: I'm not sure this is the best place to put this prototype...*/
  267. /**
  268.  * Generate random bytes.
  269.  * @param buf Buffer to fill with random bytes
  270.  * @param length Length of buffer in bytes (becomes apr_size_t in APR 1.0)
  271.  */
  272. #ifdef APR_ENABLE_FOR_1_0
  273. APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, 
  274.                                                     apr_size_t length);
  275. #else
  276. APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, 
  277.                                                     int length);
  278. #endif
  279.  
  280. #endif
  281. /** @} */
  282.  
  283. #ifdef __cplusplus
  284. }
  285. #endif
  286.  
  287. #endif  /* ! APR_GENERAL_H */
  288.